# (1) 编写一个函数，获取用户输入圆的半径。使用圆的周长和面积公式计算并打印出输入半径的圆的周长和面积。

# def get_area_perimeter(r):
#     pai = 3.1415926
#
#     a = round(pai * r * r, 5)
#     p = round(2 * pai * r, 5)
#     return a, p
#
#
# r = int(input("请输入圆的半径"))
# area, perimeter = get_area_perimeter(10)
# print("面积：", area)
# print("周长：", perimeter)

# (2) 编写一个函数，计算BMI并给出健康建议

# def get_bmi_advise(weight, height):
#     bmi = weight / (height ** 2)
#
#     if bmi < 18.5:
#         advise = f"您的BMI的值{bmi:.3}，体重过轻，建议多吃少动"
#     elif 18.5 <= bmi < 24:
#         advise = f"您的BMI的值{bmi:.3}，体重正常，建议保持！"
#     elif 24 <= bmi < 28:
#         advise = f"您的BMI的值{bmi:.3}，体重稍胖，建议多动少吃！"
#     else:
#         advise = f"您的BMI的值{bmi:.3}，太肥胖，建议绝食！"
#
#     return advise
#
#
# # 获取用户输入的身高和体重
# height = float(input("请输入您的身高（单位：米）："))
# weight = float(input("请输入您的体重（单位：千克）："))
#
# ad = get_bmi_advise(weight, height)
#
# print("我们的建议：", ad)


# # (3) 编写一个函数，输入长度，获取该长度的随机验证码
# import random
# import string


# def get_random_code(n):
#     count = 0
#     s = ""
#     while count < n:
#         # 逻辑代码块开始
#         char = random.choice(string.digits + string.ascii_letters)
#         # print(char)
#         s += char
#         # 逻辑代码块结束
#         count += 1
#
#     return s
#
#
# print(get_random_code(10))
# print(get_random_code(20))
# print(get_random_code(30))


# (4) 编写一个函数，计算列表中所有元素的平均值的函数，参数为列表

# def cal_list_average(l):
#     return round(sum(l) / len(l), 2)
#
#
# l = [1, 2, 3, 4, 5]
# print(cal_list_average(l))

# (5) 编写一个函数，接收一个整数作为参数，返回该整数的阶乘


# def get_factorial(n):
#     ret = 1
#     for i in range(1, n + 1):
#         ret *= i
#
#     return ret
#
#
# print(get_factorial(5))
# print(get_factorial(10))
# print(get_factorial(15))


# (6)
# def foo(x):
#     x = x[:]
#     # x = x.copy()
#     x[0] = 100
#     x.append(4)
#     print(x)
#
# l = [1, 2, 3]
# foo(l)
# print(l)

# (7)
# x = 10


# def my_func():
#     print(x)
#
#
# def outer():
#     x = 20
#     my_func()
#
#
# def outer2():
#     x = 30
#     my_func()
#
#
# outer()

print(eval("sum([2 * 3 + 6, (5 - 9) + 7 - 2, 13 * 4 - 11])"))
